package com.windoent.yugioh.adapter.brvah;

import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.RankListBean;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.LogUtils;
import com.windoent.yugioh.utils.SimpleUtils;
import com.windoent.yugioh.widget.RoundImageView;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :
 */
public class PointIntegralRankAdapter extends BaseQuickAdapter<RankListBean.DataBean.PersonalBean, BaseViewHolder> {

    public PointIntegralRankAdapter() {
        super(R.layout.item_list_integral_rank, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RankListBean.DataBean.PersonalBean item) {
        helper.setText(R.id.tv_numbers, BaseMethod.notNullDefaultValueNull(item.getRank() + ""))
                .setText(R.id.tv_name, BaseMethod.notNullDefaultValueNull(item.getNickName()))
                .setText(R.id.tv_point, BaseMethod.notNullDefaultValueNull(item.getPoints() + ""));

        RoundImageView iv_avatar = helper.getView(R.id.iv_avatar);
        SimpleUtils.loadImageForView(getContext(), iv_avatar, item.getAvatar(), R.drawable.img_official_avatar_android);

        int layoutPosition = helper.getLayoutPosition();
        RelativeLayout mLlParent = helper.getView(R.id.rl_rank);
        if (layoutPosition == 1 && layoutPosition == getData().size()) {
            mLlParent.setBackgroundResource(R.drawable.drawable_point_rv_one_bg);
        } else if (layoutPosition == 1) {
            mLlParent.setBackgroundResource(R.drawable.drawable_point_rv_bg);
        } else if (layoutPosition == getData().size()) {
            mLlParent.setBackgroundResource(R.drawable.drawable_point_rv_end_bg);
        } else {
            mLlParent.setBackgroundResource(R.drawable.drawable_point_rv_center_bg);
        }
    }
}